package com.stone.design.mode.state.spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 测试
 *
 * @author wenpan 2022/06/18 17:32
 */
@SpringBootApplication
public class Test {

    public static void main(String[] args) {
        Thread.currentThread().setName("主线程");
        ConfigurableApplicationContext context = SpringApplication.run(Test.class, args);
        OrderService orderService = (OrderService) context.getBean("orderService");
        // 创建订单
        orderService.create();
        orderService.create();
        // 支付一号订单
        orderService.pay(1);

//        new Thread("客户线程") {
//            @Override
//            public void run() {
//                // 用户线程对1号订单进行发货
//                orderService.deliver(1);
//                // 用户线程对1号订单进行收货
//                orderService.receive(1);
//            }
//        }.start();
//
//        orderService.pay(2);
//        orderService.deliver(2);
//        orderService.receive(2);

        System.out.println("全部订单状态：" + orderService.getOrders());

    }
}
